import { observable, action, computed } from 'mobx';

class State {
    @observable a = 0;

    @computed
    get b() {
        return this.a + 3;
    }

    @observable sipVehicle = [
        {
            name: '姓名',
            value: ''
        },
        {
            name: '性别',
            value: ''
        },
        {
            name: '籍贯',
            value: ''
        },
        {
            name: '爱好',
            value: ''
        },
        {
            name: '美食',
            value: ''
        }
    ]

    @observable noRepairedData = []

    @observable hadRepairedData = []

    @observable pointData = []
}

class Actions {
    constructor( { state } ) {
        this.state = state;
    }

    @action
    add = () => {
        this.state.a++;
    }

    @action
    reduce = () => {
        this.state.a--;
    }

    @action
    getSipCollect = ( index ) => {
        setTimeout( () => {
            switch ( index ) {
                case '0':
                    this.state.noRepairedData = [
                        {
                            key: '1',
                            index: 1,
                            defectName: '安装精度不准确',
                            level: 'S',
                            position: '车门(235，113)',
                            detail: '门把手孔没对准',
                            time: '2018-07-12'
                        },
                        {
                            key: '2',
                            index: 2,
                            defectName: '安装精度不准确',
                            level: 'A',
                            position: '车门(235，113)',
                            detail: '门把手孔没对准',
                            time: '2018-07-12'
                        },
                        {
                            key: '3',
                            index: 3,
                            defectName: '安装精度不准确',
                            level: 'B',
                            position: '车门(235，113)',
                            detail: '门把手孔没对准',
                            time: '2018-07-12'
                        }
                    ];
                    break;
                case '1':
                    this.state.hadRepairedData = [
                        {
                            key: '1',
                            index: 1,
                            defectName: '安装精度不准确',
                            level: 'S',
                            position: '车门(235，113)',
                            detail: '门把手孔没对准',
                            time: '2018-07-12',
                            user: '张三',
                            messure: '重新安装',
                            responseArea: 'SD一车间',
                            reason: '睡着了',
                            site: 'GG23'
                        },
                        {
                            key: '2',
                            index: 2,
                            defectName: '安装精度不准确',
                            level: 'A',
                            position: '车门(235，113)',
                            detail: '门把手孔没对准',
                            time: '2018-07-12',
                            user: '张三',
                            messure: '重新安装',
                            responseArea: 'SD一车间',
                            reason: '睡着了',
                            site: 'GG23'
                        },
                        {
                            key: '3',
                            index: 3,
                            defectName: '安装精度不准确',
                            level: 'B',
                            position: '车门(235，113)',
                            detail: '门把手孔没对准',
                            time: '2018-07-12',
                            user: '张三',
                            messure: '重新安装',
                            responseArea: 'SD一车间',
                            reason: '睡着了',
                            site: 'GG23'
                        }
                    ];
                    break;
                case '2':
                    this.state.pointData = [
                        {
                            key: '1',
                            index: 1,
                            defectName: '安装精度不准确',
                            level: 'S',
                            position: '车门(235，113)',
                            detail: '门把手孔没对准',
                            time: '2018-07-12'
                        },
                        {
                            key: '2',
                            index: 2,
                            defectName: '安装精度不准确',
                            level: 'A',
                            position: '车门(235，113)',
                            detail: '门把手孔没对准',
                            time: '2018-07-12'
                        },
                        {
                            key: '3',
                            index: 3,
                            defectName: '安装精度不准确',
                            level: 'B',
                            position: '车门(235，113)',
                            detail: '门把手孔没对准',
                            time: '2018-07-12'
                        }
                    ];
                    break;
            }
        }, 100 )


    }


}

const state = new State();

export default new Actions( { state } );

